﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using SdmxMl.Structure;
using SdmxMl.Panels;

namespace SdmxMl.UC
{
    public partial class UcStructureSets : UserControl
    {
        protected TreeNode treeNode;
        protected MapList _map;
        private PanelAnnotationList pannelAnnot;
        private bool _isFinal;

        public UcStructureSets()
        {
            InitializeComponent();
        }

        public virtual void BindFromNode(TreeNode node, PanelAnnotationList panelAnnotation, bool isFinal)
        {
            treeNode = node;
            pannelAnnot = panelAnnotation;
            _isFinal = isFinal;
            _map = null;

            if (node != null)
            {
                _map = node.Tag as MapList;
            }
            BindToControls();

        }

        private void BindToControls()
        {
            if (_map != null)
            {
                Visible = true;
                ucBaseSetMap1.BindMap(_map.Maps.CodelistMap.MapList, pannelAnnot, _isFinal);

            }
            else
                Visible = false;
        }

        public bool UpdateNodeTag(TreeNode node)
        {
            bool err = false;
            if (node != null)
            {
                err = BindFromControls();
            }

            return err; // true on error
        }

        protected bool BindFromControls()
        {
            bool err = false;
            if (_map != null)
            {
                ucBaseSetMap1.BindFromControls();
            }
            return err;
        }

    }
}
